#ifndef VERTEXELEMENT_H
#define VERTEXELEMENT_H

#include "Framework/Prerequisites.h"

namespace tyro
{
	namespace Graphics
	{
		class VertexElement
		{
		public:

			VertexElement(){}
			VertexElement(UINT_32 source, size_t memOffset, VertexElementType type, VertexElementSemantic semantic, UINT_32 index = 0);

			static size_t GetTypeSize( VertexElementType vetype );
			static USHORT_16 GetTypeCount( VertexElementType vetype );


			VertexElementSemantic GetSemantic( void ) const;
			VertexElementType GetType( void ) const;
			UINT_32 GetSource( void ) const;
			size_t GetMemOffset(void) const { return memOffset; }
			USHORT_16 GetIndex(void) const { return index; }


			inline void SetBasePointerToElement(void* basePtr, FLOAT_32** elem) const;
			inline void SetBasePointerToElement(void* basePtr, RGBA** elem) const;


		protected:

			UINT_32					source;
			size_t					memOffset;
			VertexElementType		type;
			VertexElementSemantic	semantic;
			UINT_32					index;

		private:
		};

		inline void VertexElement::SetBasePointerToElement( void* basePtr, FLOAT_32** elem ) const
		{
			*elem = static_cast<FLOAT_32*>(
					static_cast<void*>(
					static_cast<UCHAR_32*>(basePtr) + memOffset));
		}

		inline void VertexElement::SetBasePointerToElement( void* basePtr, RGBA** elem ) const
		{
			*elem = static_cast<RGBA*>(
				static_cast<void*>(
				static_cast<UCHAR_32*>(basePtr) + memOffset));
		}
	}
}
#endif